package com.hefeng.unit.service.impl;


import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hefeng.common.core.domain.MapEntity;
import com.hefeng.common.core.utils.AmapUtil;
import com.hefeng.common.core.utils.DateUtils;
import com.hefeng.common.core.utils.EmptyUtils;
import com.hefeng.unit.common.StartLoadingParameter;
import com.hefeng.unit.domain.*;
import com.hefeng.unit.mapper.GyDeviceMapper;
import com.hefeng.unit.mapper.GyDeviceSonMapper;
import com.hefeng.unit.mapper.GyDeviceUserMapper;
import com.hefeng.unit.mapper.GyUserMapper;
import com.hefeng.unit.service.GyDeviceService;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.web.client.RestTemplate;

import java.util.*;

/**
 * 设备信息表;(gy_device)表服务实现类
 *
 * @author : http://www.chiner.pro
 * @date : 2022-11-29
 */
@Service
public class GyDeviceServiceImpl extends ServiceImpl<GyDeviceMapper, GyDevice> implements GyDeviceService {
    @Autowired
    private GyDeviceMapper gyDeviceMapper;
    @Autowired
    private GyUserMapper gyUserMapper;
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private GyDeviceUserMapper gyDeviceUserMapper;
    @Autowired
    private GyDeviceSonMapper gyDeviceSonMapper;




    /**
     * 通过ID查询单条数据
     *
     * @param deviceId 主键
     * @return 实例对象
     */
    @Override
    public GyDevice queryById(Integer deviceId) {
        return gyDeviceMapper.selectById(deviceId);
    }

    /**
     * 分页查询
     *
     * @param gyDevice 筛选条件
     * @param
     * @param
     * @return
     */
    @Override
    public Page<GyDevice> paginQuery(GyDevice gyDevice) {
        Page<GyDevice> pagin = new Page<>(gyDevice.getPageNum(), gyDevice.getPageSize());
        //1. 构建动态查询条件
        LambdaQueryWrapper<GyDevice> queryWrapper = new LambdaQueryWrapper<>();

        if (StrUtil.isNotBlank(gyDevice.getIsHost())) {
            queryWrapper.eq(GyDevice::getIsHost, gyDevice.getIsHost());
        }
        if (StrUtil.isNotBlank(gyDevice.getDeviceCode())) {
            queryWrapper.eq(GyDevice::getDeviceCode, gyDevice.getDeviceCode());
        }
        if (StrUtil.isNotBlank(gyDevice.getUserId())) {
            queryWrapper.eq(GyDevice::getUserId, gyDevice.getUserId());
        }
        if (StrUtil.isNotBlank(gyDevice.getDeviceThumPic())) {
            queryWrapper.eq(GyDevice::getDeviceThumPic, gyDevice.getDeviceThumPic());
        }
        if (StrUtil.isNotBlank(gyDevice.getDeviceModel())) {
            queryWrapper.eq(GyDevice::getDeviceModel, gyDevice.getDeviceModel());
        }
        if (StrUtil.isNotBlank(gyDevice.getDeviceImei())) {
            queryWrapper.eq(GyDevice::getDeviceImei, gyDevice.getDeviceImei());
        }
        if (StrUtil.isNotBlank(gyDevice.getDeviceInfo())) {
            queryWrapper.eq(GyDevice::getDeviceInfo, gyDevice.getDeviceInfo());
        }
        if (StrUtil.isNotBlank(gyDevice.getDeviceId())) {
            queryWrapper.eq(GyDevice::getDeviceId, gyDevice.getDeviceId());
        }
        if (StrUtil.isNotBlank(gyDevice.getDeviceLongitude())) {
            queryWrapper.eq(GyDevice::getDeviceLongitude, gyDevice.getDeviceLongitude());
        }
        if (StrUtil.isNotBlank(gyDevice.getDeviceLatitude())) {
            queryWrapper.eq(GyDevice::getDeviceLatitude, gyDevice.getDeviceLatitude());
        }
        if (StrUtil.isNotBlank(gyDevice.getUserId())) {
            queryWrapper.eq(GyDevice::getUserId, gyDevice.getUserId());
        }
        if (StrUtil.isNotBlank(gyDevice.getAdcode())) {
            queryWrapper.eq(GyDevice::getAdcode, gyDevice.getAdcode());
        }
        if (StrUtil.isNotBlank(gyDevice.getTowncode())) {
            queryWrapper.eq(GyDevice::getTowncode, gyDevice.getTowncode());
        }

        if (StrUtil.isNotBlank(gyDevice.getDeviceManufacturer())) {
            queryWrapper.eq(GyDevice::getDeviceManufacturer, gyDevice.getDeviceManufacturer());
        }
        if (StrUtil.isNotBlank(gyDevice.getDeviceLimitValue())) {
            queryWrapper.eq(GyDevice::getDeviceLimitValue, gyDevice.getDeviceLimitValue());
        }

        IPage<GyDevice> gyDevicePage = gyDeviceMapper.selectPage(pagin, queryWrapper);

        //3. 返回结果
        return (Page<GyDevice>) gyDevicePage;
    }

    /**
     * 工业新增设备
     *
     * @param gyDevice 实例对象
     * @return
     */
    @Override
    public Map<String, Object> insert(GyDevice gyDevice) {
        Map<String, Object> dataMap = new HashMap<>();
        //查询设备code是否存在
        if (StrUtil.isBlank(gyDevice.getDeviceCode())) {
            dataMap.put("make", false);
            dataMap.put("msg", "设备code不能为空！");
            return dataMap;
        }
//        验证设备是否添加到采集平台
//        JSONObject obj=restTemplate.getForObject(StartLoadingParameter.QUERYBYDEVICECODE+gyDevice.getDeviceCode(), JSONObject.class);
//        if(!obj.has("obj")){
//            dataMap.put("make",false);
//            dataMap.put("msg","未查询到该设备，请联系运维人员！");
//            return dataMap;
//        }
        //验证设备是否在录入
        LambdaQueryWrapper<GyDeviceUser> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(GyDeviceUser::getDeviceCode, gyDevice.getDeviceCode());
        queryWrapper.eq(GyDeviceUser::getIsDelete, "1");
        //只能一个人添加设备
        //queryWrapper.eq(WxDeviceUser::getUserId,wxDevice.getUserId());
        GyDeviceUser deviceUser = gyDeviceUserMapper.selectOne(queryWrapper);
        if (EmptyUtils.isNotEmpty(deviceUser)) {
            dataMap.put("make", false);
            dataMap.put("msg", "设备已存在！");
            return dataMap;
        }
        //获取设备城市编码
        MapEntity gas = AmapUtil.getTowncodeByLocation(gyDevice.getDeviceLongitude(), gyDevice.getDeviceLatitude());
        gyDevice.setCitycode(gas.getCitycode());
        gyDevice.setAdcode(gas.getAdcode());
        gyDevice.setTowncode(gas.getTowncode());
        //厂家信息
        //gyDevice.setManufacturerCode("");
        //设备阈值
        gyDevice.setDeviceLimitValue("%7LEL");
        //是否删除;（1：正常  2：删除）
        gyDevice.setIsDeleted(1);
        gyDevice.setIsHost(String.valueOf(1));



        //创建时间
        gyDevice.setCreatedTime(new Date());
        //设备激活时间
        gyDevice.setDeviceActiveTime(new Date());
        //设备报废时间
        Date date = DateUtils.addYears(new Date(), 3);
        gyDevice.setDeviceScrapTime(date);



        //添加子设备表
        //可以单独传入http参数，这样参数会自动做URL编码，拼接在URL中
        HashMap<String, Object> paramMap = new HashMap<>();
        paramMap.put("alarmHostCode", gyDevice.getDeviceCode());
        String result3 = HttpUtil.get("http://47.109.55.87:18081/gasApi/collection/deviceInfo/wxGetAegisDetectorInfoList", paramMap);
        com.alibaba.fastjson.JSONObject j = JSON.parseObject(result3);
        com.alibaba.fastjson.JSONObject jsonData = j.getJSONObject("obj");//解析JSON的body
        JSONObject a = jsonData.getJSONObject("twoPeriod");
        JSONObject b = jsonData.getJSONObject("onePeriod");



        if (ObjectUtil.isNotNull(a)) {
            /**jsonobj
             * **/
            JSONObject hostFactory = a.getJSONObject("aegisAlarmHostInfo");
            //com.alibaba.fastjson.JSONObject ee = hostFactory.getJSONObject();

            gyDevice.setDeviceManufacturer(hostFactory.getString("hostFactory"));
            gyDeviceMapper.insert(gyDevice);

            JSONArray jsonArray = a.getJSONArray("deviceList");//解析JSON的data数据
            JSONObject row = null;//定义一个空变量

            for (int y = 0; y < jsonArray.size(); ++y) {

                com.alibaba.fastjson.JSONObject jsonObject = jsonArray.getJSONObject(y); //获取
                //修改子设备信息  往pc端推送
                DeviceInfo son = new DeviceInfo();
                son.setDeviceCode(jsonObject.getString("deviceCode"));
                //0.工业端 1.居民端
                son.setDeviceInstallationType(String.valueOf(0));
                //经度
                son.setLongitude(Double.parseDouble(gyDevice.getDeviceLongitude()));
                //经度
                son.setLatitude(Double.parseDouble(gyDevice.getDeviceLatitude()));
                //设备安装地址
                son.setDeviceAddress(gyDevice.getDeviceAddress());
                //市编码
                son.setCity(gyDevice.getCitycode());
                //设备名称
                son.setDeviceName(gyDevice.getDeviceName());
                //区域编码
                son.setDistrict(gyDevice.getAdcode());
                //街道编码
                son.setStreet(gyDevice.getTowncode());
                restTemplate.put(StartLoadingParameter.DEVICEUPDATEINFO, son);


                //获取子设备
                GyDeviceSon savehttp = new GyDeviceSon();
                row = jsonArray.getJSONObject(y);
                savehttp.setSonCode(jsonObject.getString("deviceCode"));
                savehttp.setDeviceName(jsonObject.getString("deviceName")+y);
                savehttp.setDeviceLocation(jsonObject.getString("deviceAddress"));
                savehttp.setDeviceType(1);
                savehttp.setDeviceId(gyDevice.getDeviceId());
                savehttp.setDeviceCode(gyDevice.getDeviceCode());
                savehttp.setCreatedTime(new Date());
                savehttp.setDeviceLatitude(gyDevice.getDeviceLatitude());
                savehttp.setDeviceLongitude(gyDevice.getDeviceLongitude());
                gyDeviceSonMapper.insert(savehttp);

                //添加到子设备用户关联表
                GyDeviceUser gyDeviceUser=new GyDeviceUser();
                GyUser user = gyUserMapper.selectById(gyDevice.getUserId());

                gyDeviceUser.setUserId(gyDevice.getUserId());
                gyDeviceUser.setDeviceId(gyDevice.getDeviceId());
                gyDeviceUser.setDeviceCode(jsonObject.getString("deviceCode"));
                gyDeviceUser.setIsDelete(1);
                gyDeviceUser.setCreatedTime(new Date());
                gyDeviceUser.setPhone(user.getPhone());
                gyDeviceUserMapper.insert(gyDeviceUser);



            }
        } else {
//            JSONArray jsonArray = b.getJSONArray("deviceList");//解析JSON的data数据
//            JSONObject row = null;//定义一个空变量
//            for (int y = 0; y < jsonArray.size(); ++y) {
//                com.alibaba.fastjson.JSONObject jsonObject = jsonArray.getJSONObject(y); //获取
//
//                //修改子设备信息  往pc端推送
//                DeviceInfo son = new DeviceInfo();
//                son.setDeviceCode(jsonObject.getString("deviceCode"));
//                //0.工业端 1.居民端
//                son.setDeviceInstallationType(String.valueOf(0));
//                //经度
//                son.setLongitude(Double.parseDouble(gyDevice.getDeviceLongitude()));
//                //经度
//                son.setLatitude(Double.parseDouble(gyDevice.getDeviceLatitude()));
//                //设备安装地址
//                son.setDeviceAddress(gyDevice.getDeviceAddress());
//                //市编码
//                son.setCity(gyDevice.getCitycode());
//                //设备名称
//                son.setDeviceName(gyDevice.getDeviceName());
//                //区域编码
//                son.setDistrict(gyDevice.getAdcode());
//                //街道编码
//                son.setStreet(gyDevice.getTowncode());
//                restTemplate.put(StartLoadingParameter.DEVICEUPDATEINFO, son);
//
//                //获取子设备
//                GyDeviceSon savehttp = new GyDeviceSon();
//                row = jsonArray.getJSONObject(y);
//                savehttp.setSonCode(jsonObject.getString("deviceCode"));
//                savehttp.setDeviceName(gyDevice.getDeviceName()+y);
//                savehttp.setDeviceLocation(jsonObject.getString("deviceAddress"));
//                savehttp.setDeviceType(1);
//                savehttp.setDeviceId(gyDevice.getDeviceId());
//                savehttp.setDeviceCode(gyDevice.getDeviceCode());
//                savehttp.setCreatedTime(new Date());
//                savehttp.setDeviceLatitude(gyDevice.getDeviceLatitude());
//                savehttp.setDeviceLongitude(gyDevice.getDeviceLongitude());
//                gyDeviceSonMapper.insert(savehttp);
//
//                //添加到子设备用户关联表
//                GyDeviceUser gyDeviceUser=new GyDeviceUser();
//                GyUser user = gyUserMapper.selectById(gyDevice.getUserId());
//                gyDeviceUser.setPhone(user.getPhone());
//                gyDeviceUser.setUserId(gyDevice.getUserId());
//                gyDeviceUser.setDeviceCode(jsonObject.getString("deviceCode"));
//                gyDeviceUser.setIsDelete(1);
//                gyDeviceUser.setCreatedTime(new Date());
//                gyDeviceUserMapper.insert(gyDeviceUser);


            gyDevice.setDeviceManufacturer("保时安");
            gyDeviceMapper.insert(gyDevice);

        }



        //添加用户关联表
        GyDeviceUser gyDeviceUser = new GyDeviceUser();
        GyUser user = gyUserMapper.selectById(gyDevice.getUserId());
        gyDeviceUser.setPhone(user.getPhone());
        gyDeviceUser.setUserId(gyDevice.getUserId());
        gyDeviceUser.setDeviceCode(gyDevice.getDeviceCode());
        gyDeviceUser.setDeviceId(gyDevice.getDeviceId());
        gyDeviceUser.setIsDelete(1);
        gyDeviceUser.setCreatedTime(new Date());
        gyDeviceUserMapper.insert(gyDeviceUser);

        //添加成功后同步到燃气公司平台
        DeviceInfo gasDeviceInfo = new DeviceInfo();
        //设备编码
        gasDeviceInfo.setDeviceCode(gyDevice.getDeviceCode());
        //经度
        gasDeviceInfo.setLongitude(Double.parseDouble(gyDevice.getDeviceLongitude()));
        //经度
        gasDeviceInfo.setLatitude(Double.parseDouble(gyDevice.getDeviceLatitude()));
        //0.工业端 1.居民端
        gasDeviceInfo.setDeviceInstallationType("0");
        //市编码
        gasDeviceInfo.setCity(gyDevice.getCitycode());
        //设备名称
        gasDeviceInfo.setDeviceName(gyDevice.getDeviceName());
        //区域编码
        gasDeviceInfo.setDistrict(gyDevice.getAdcode());
        //街道编码
        gasDeviceInfo.setStreet(gyDevice.getTowncode());
        //设备安装地址
        gasDeviceInfo.setDeviceAddress(gyDevice.getDeviceAddress());
        //小区名称
        gasDeviceInfo.setDeviceRemarks(user.getUnitName());

        restTemplate.put(StartLoadingParameter.DEVICEUPDATEINFO, gasDeviceInfo);

        dataMap.put("make", true);

        return dataMap;
    }


    /**
     * 更新数据
     *
     * @param
     * @return 实例对象
     */
    @Override
    public Map<String, Object> update(List<GyDevice> gyDeviceList) {


        Map<String, Object> dataMap = new HashMap<>();

        try {
            for(GyDevice gyDevice:gyDeviceList){
               if (StringUtils.isBlank(gyDevice.getIsHost())){
                    continue;
               }
               if (gyDevice.getIsHost().equals("1")){
                   //1. 根据条件动态更新
                   LambdaQueryWrapper<GyDevice> queryWrapper = new LambdaQueryWrapper<>();

                   queryWrapper.eq(GyDevice::getDeviceId, gyDevice.getDeviceId());
                   //获取设备城市编码
                   MapEntity gas = AmapUtil.getTowncodeByLocation(gyDevice.getDeviceLongitude(), gyDevice.getDeviceLatitude());

                   gyDevice.setCitycode(gas.getCitycode());

                   gyDevice.setAdcode(gas.getAdcode());

                   gyDevice.setTowncode(gas.getTowncode());

                   gyDeviceMapper.update(gyDevice, queryWrapper);
               }


                // GyDevice device = gyDeviceMapper.selectOne(queryWrapper);

                DeviceInfo gasDeviceInfo = new DeviceInfo();
                //设备编码
                gasDeviceInfo.setDeviceCode(gyDevice.getDeviceCode());
                //经度
                gasDeviceInfo.setLongitude(Double.parseDouble(gyDevice.getDeviceLongitude()));
                //经度
                gasDeviceInfo.setLatitude(Double.parseDouble(gyDevice.getDeviceLatitude()));
                //0.工业端 1.居民端
                gasDeviceInfo.setDeviceInstallationType("0");
                //市编码
                gasDeviceInfo.setCity(gyDevice.getCitycode());
                //设备名称
                gasDeviceInfo.setDeviceName(gyDevice.getDeviceName());
                //区域编码
                gasDeviceInfo.setDistrict(gyDevice.getAdcode());
                //街道编码
                gasDeviceInfo.setStreet(gyDevice.getTowncode());
                //设备安装地址
                gasDeviceInfo.setDeviceAddress(gyDevice.getDeviceAddress());
                //小区名称
                restTemplate.put(StartLoadingParameter.DEVICEUPDATEINFO, gasDeviceInfo);

                dataMap.put("make", true);

                dataMap.put("device", gyDevice);
            }


        } catch (Exception e) {

            dataMap.put("msg", "修改失败！");

        }
        return dataMap;
    }

    /**
     * 通过主键删除数据
     *
     * @param deviceId 主键
     * @return 是否成功
     */
    @Override
    public Map<String, Object> deleteById(String deviceId) {

        Map<String, Object> data = new HashMap<>();
        try {
            LambdaQueryWrapper<GyDeviceUser> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(GyDeviceUser::getDeviceId, deviceId);
            GyDeviceUser wxDeviceUser = new GyDeviceUser();
            wxDeviceUser.setIsDelete(2);
            gyDeviceUserMapper.update(wxDeviceUser, queryWrapper);


//            LambdaQueryWrapper<GyDeviceSon> queryWrapper1 = new LambdaQueryWrapper<>();
//            queryWrapper1.eq(GyDeviceSon::getDeviceId,deviceId);
//            GyDeviceSon gyDeviceSon=new GyDeviceSon();
//            gyDeviceSon.setDeviceType(2);
//            gyDeviceSonMapper.deviceSon(deviceId);

//            LambdaQueryWrapper<GyDevice> queryWrapper2 = new LambdaQueryWrapper<>();
//            queryWrapper2.eq(GyDevice::getDeviceId,deviceId);
//            GyDevice gyDevice=new GyDevice();
//            gyDevice.setIsDeleted(2);
//           gyDeviceMapper.device(deviceId);



            data.put("make", true);
        } catch (Exception e) {
            data.put("make", false);
            data.put("msg", "删除失败！");
        }

        return data;
    }

    /**
     * 根据userid获取设备状态数量
     *
     * @param userId
     * @return
     */
    @Override
    public List<Map> quantity(@Param("userId") String userId) {


        return gyDeviceMapper.quantity(userId);
    }

    @Override
    public Map<String, Object> independent(GyDevice gyDevice) {
        Map<String, Object> dataMap = new HashMap<>();
        //查询设备code是否存在
        if (StrUtil.isBlank(gyDevice.getDeviceCode())) {
            dataMap.put("make", false);
            dataMap.put("msg", "设备code不能为空！");
            return dataMap;
        }
        //验证设备是否添加到采集平台
        net.sf.json.JSONObject obj = restTemplate.getForObject(StartLoadingParameter.QUERYBYDEVICECODE + gyDevice.getDeviceCode(), net.sf.json.JSONObject.class);
        if (!obj.has("obj")) {
            dataMap.put("make", false);
            dataMap.put("msg", "未查询到该设备，请联系运维人员！");
            return dataMap;
        }
        //验证设备是否在录入
        LambdaQueryWrapper<GyDeviceUser> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(GyDeviceUser::getDeviceCode, gyDevice.getDeviceCode());
        queryWrapper.eq(GyDeviceUser::getIsDelete, "1");
        //只能一个人添加设备
        //queryWrapper.eq(WxDeviceUser::getUserId,wxDevice.getUserId());
        GyDeviceUser deviceUser = gyDeviceUserMapper.selectOne(queryWrapper);
        if (EmptyUtils.isNotEmpty(deviceUser)) {
            dataMap.put("make", false);
            dataMap.put("msg", "设备已存在！");
            return dataMap;
        }
        //获取设备城市编码
        MapEntity gas = AmapUtil.getTowncodeByLocation(gyDevice.getDeviceLongitude(), gyDevice.getDeviceLatitude());
        gyDevice.setCitycode(gas.getCitycode());
        gyDevice.setAdcode(gas.getAdcode());
        gyDevice.setTowncode(gas.getTowncode());
        //设备型号
        gyDevice.setDeviceModel("安可信");
        //独立式
        gyDevice.setIsHost(String.valueOf(2));
        gyDevice.setDeviceManufacturer("安可信");
        //设备阈值
        gyDevice.setDeviceLimitValue("%7LEL");
        //是否删除;（1：正常  2：删除）
        gyDevice.setIsDeleted(1);
        //设备缩略图
        gyDevice.setDeviceThumPic("https://hefengzhxf.oss-cn-guangzhou.aliyuncs.com/gas/3c102b4282157cd89f9e8f53b4f1335.png");
        //创建时间
        gyDevice.setCreatedTime(new Date());
        //设备激活时间
        gyDevice.setDeviceActiveTime(new Date());
        //设备报废时间
        Date date = DateUtils.addYears(new Date(), 3);
        gyDevice.setDeviceScrapTime(date);
        int i = gyDeviceMapper.insert(gyDevice);
        //添加用户关联表
        GyDeviceUser wxDeviceUser = new GyDeviceUser();
        GyUser user = gyUserMapper.selectById(gyDevice.getUserId());
        wxDeviceUser.setPhone(user.getPhone());
        wxDeviceUser.setUserId(gyDevice.getUserId());
        wxDeviceUser.setDeviceCode(gyDevice.getDeviceCode());
        wxDeviceUser.setDeviceId(gyDevice.getDeviceId());

        wxDeviceUser.setIsDelete(1);
        wxDeviceUser.setCreatedTime(new Date());
        gyDeviceUserMapper.insert(wxDeviceUser);

        //添加成功后同步到燃气公司平台
        DeviceInfo gasDeviceInfo = new DeviceInfo();
        //设备编码
        gasDeviceInfo.setDeviceCode(gyDevice.getDeviceCode());
        //经度
        gasDeviceInfo.setLongitude(Double.parseDouble(gyDevice.getDeviceLongitude()));
        //经度
        gasDeviceInfo.setLatitude(Double.parseDouble(gyDevice.getDeviceLatitude()));
        //0.工业端 1.居民端
        gasDeviceInfo.setDeviceInstallationType("1");
        //市编码
        gasDeviceInfo.setCity(gyDevice.getCitycode());
        //设备名称
        gasDeviceInfo.setDeviceName(gyDevice.getDeviceName());
        //区域编码
        gasDeviceInfo.setDistrict(gyDevice.getAdcode());
        //街道编码
        gasDeviceInfo.setStreet(gyDevice.getTowncode());
        //设备安装地址
        gasDeviceInfo.setDeviceAddress(gyDevice.getDeviceAddress());

        restTemplate.put(StartLoadingParameter.DEVICEUPDATEINFO, gasDeviceInfo);

        dataMap.put("make", true);

        return dataMap;
    }

    @Override
    public List<Map> listT(String userId, String isHost) {
        return gyDeviceMapper.list(userId, isHost);
    }

    @Override
    public int update(String deviceId) {
             LambdaQueryWrapper<GyDevice> queryWrapper2 = new LambdaQueryWrapper<>();
            queryWrapper2.eq(GyDevice::getDeviceId,deviceId);
            GyDevice gyDevice=new GyDevice();
            gyDevice.setIsDeleted(2);
          return gyDeviceMapper.update(gyDevice,queryWrapper2);
    }


}
